<?php
/**
 * 简历管理
 * 
 * @author  Lee<a605333742@gmail.com>
 * @time    2016-07-30
 */
namespace Admin\Controller;

class ResumeController extends CommonController{
    /*
     * 构造函数
     * 
     * @return  #
     */
    public function _initialize() {
        parent::_initialize();
        $this->db       =new \Model\ResumeModel();
    }
    
    /*
     * 简历列表(所有人都可以查看已审核的简历)
     * 
     * @return #
     */
    public function index(){
        $map=$this->_search("Resume");
        $map['state']   =2;
        $sortBy         ="top";
        $sort           =desc;
        $resumeList     =$this->_list($this->db,$map,$sortBy,$sort);
        $this->assign("resumeList",$resumeList);
        $this->assign("act",1);
        $this->display();
    }
    
    /*
     * 待审核简历，只有管理员可以看
     * 
     * @return #
     */
    public function auditResume(){
        $map=$this->_search("Resume");
        $map['state']   =1;
        $sortBy         ="top";
        $sort           =desc;
        $resumeList     =$this->_list($this->db,$map,$sortBy,$sort);
        $this->assign("resumeList",$resumeList);
        $this->assign("act",2);
        $this->display("index");
    }
    
    /*
     * 查看工作经验
     * 
     * @return #
     */
    public function show(){
        $id     =I("request.id",'','int');
        $expList=D("experience")->where(array("resumeId"=>$id))->select();
        //show_bug($expList);exit;
        $this->assign("expList",$expList);
        $this->display();
    }
    
    /*
     * 审核批量审核简历
     * 
     * @return #
     */
    public function alledit(){
        $map['id']      =I("request.id");
        $map['state']   =2;
        if($this->db->edits($map)){            
            $this->success("审核成功",U("index"));
        }else{
            $this->error("审核失败",U("index"));
        }        
    }
    
     /*
     * 待审核，批量待审核
     * 
     * @return #
     */
    public function audit(){
        $map['id']      =I("request.id");
        $map['state']   =1;
        if($this->db->edits($map)){            
            $this->success("待审核成功",U("index"));
        }else{
            $this->error("待审核失败",U("index"));
        }
    }
    
    /*
     * 删除，批量删除求购信息
     * 
     * @return #
     */
    public function del(){
        $map['id']      =I("request.id");
        $map['state']   =3;
        if($this->db->edits($map)){            
            $this->success("删除成功",U("index"));
        }else{
            $this->error("删除失败",U("index"));
        }
    }
}


